<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="link" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{linkHome.managed ? 'Edit' : 'Add'} Link</f:facet>



            <s:decorate id="destinationField" template="layout/edit.xhtml">
                <ui:define name="label">Destination</ui:define>
                <h:inputTextarea id="destination"
                               cols="80"
                               rows="3"
                              value="#{linkHome.instance.destination}"/>
            </s:decorate>



            <s:decorate id="nameField" template="layout/edit.xhtml">
                <ui:define name="label">Name</ui:define>
                <h:inputTextarea id="name"
                               cols="80"
                               rows="3"
                              value="#{linkHome.instance.name}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{linkHome.persist}"
                       disabled="#{!linkHome.wired}"
                       rendered="#{!linkHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{linkHome.update}"
                       rendered="#{linkHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{linkHome.remove}"
                      immediate="true"
                       rendered="#{linkHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Link.xhtml"
                rendered="#{linkHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty linkFrom ? 'LinkList' : linkFrom}.xhtml"
                rendered="#{!linkHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Folder bean *" labelClass="required">
    <div class="association" id="folderBeanParent">

        <h:outputText value="There is no folderBean associated with this link."
                   rendered="#{linkHome.instance.folderBean == null}"/>

        <rich:dataTable var="_folder"
                   value="#{linkHome.instance.folderBean}"
                rendered="#{linkHome.instance.folderBean != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="folderBeanTable">
            <h:column>
                <f:facet name="header">Id folder</f:facet>
                <h:outputText value="#{_folder.idFolder}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Foldername</f:facet>
                <h:outputText value="#{_folder.foldername}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{linkHome.instance.folderBean != null ? 'changeParent' : 'selectParent'}" value="#{linkHome.instance.folderBean != null ? 'Change' : 'Select'} folderBean"
                       view="/FolderList.xhtml">
                <f:param name="from" value="LinkEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
